import Vue from 'vue'
import VueRouter from 'vue-router'

const Login = () => import('../views/Login/Login.vue')
const Index = () => import('../views/Index/Index.vue')
const StatusMonitor = () => import('../views/StatusMonitor/StatusMonitor.vue')
const RunControl = () => import('../views/RunControl/RunControl.vue')
const CallPolice = () => import('../views/CallPolice/CallPolice.vue')
const SEOP = () => import('../views/SEOP/SEOP.vue')
const TeachTemplate = () => import('../views/TeachTemplate/TeachTemplate.vue')
const ControlTemplate = () => import('../views/ControlTemplate/ControlTemplate.vue')

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    redirect: '/StatusMonitor',
  },
  {
    path: '/Login',
    name: '登录',
    component: Login
  },
  {
    path: '/Index',
    name: '首页 ',
    component: Index,
    children: [
      {
        path: '/StatusMonitor',
        name: '状态控制',
        component: StatusMonitor
      },

      {
        path: '/RunControl',
        name: '运行控制',
        component: RunControl
      },
      {
        path: '/CallPolice',
        name: '报警',
        component: CallPolice
      },
      {
        path: '/SEOP',
        name: '档案袋',
        component: SEOP
      },
      {
        path: '/TeachTemplate',
        name: '计算控制',
        component: TeachTemplate
      },
      {
        path: '/ControlTemplate',
        name: '仪表盘',
        component: ControlTemplate
      },
    ]
  }

]

const router = new VueRouter({
  routes
})

export default router
